home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / c_eval.zip / EE.H < prev    next >
Text File  |  1992-06-04  |  2KB  |  45 lines

  1. /* Some of you may choose to define TYPE as a "float" instead... */
  2. #define TYPE            double          /* Type of numbers to work with */
  3.  
  4. #define VARLEN          15              /* Max length of variable names */
  5. #define MAXVARS         50              /* Max user-defined variables */
  6. #define TOKLEN          30              /* Max token length */
  7.  
  8. #define VAR             1
  9. #define DEL             2
  10. #define NUM             3
  11.  
  12. typedef struct
  13. {
  14.    char name[VARLEN + 1];               /* Variable name */
  15.    TYPE value;                          /* Variable value */
  16. } VARIABLE;
  17.  
  18. typedef struct
  19. {
  20.    char* name;                          /* Function name */
  21.    int   args;                          /* Number of arguments to expect */
  22.    TYPE  (*func)();                     /* Pointer to function */
  23. } FUNCTION;
  24.  
  25. /* The following macros are ASCII dependant, no EBCDIC here! */
  26. #define iswhite(c)  (c == ' ' || c == '\t')
  27. #define isnumer(c)  ((c >= '0' && c <= '9') || c == '.')
  28. #define isalpha(c)  ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') \
  29.                     || c == '_')
  30. #define isdelim(c)  (c == '+' || c == '-' || c == '*' || c == '/' || c == '%' \
  31.                     || c == '^' || c == '(' || c == ')' || c == ',' || c == '=')
  32.  
  33. /* Codes returned from the evaluator */
  34. #define E_OK           0        /* Successful evaluation */
  35. #define E_SYNTAX       1        /* Syntax error */
  36. #define E_UNBALAN      2        /* Unbalanced parenthesis */
  37. #define E_DIVZERO      3        /* Attempted division by zero */
  38. #define E_UNKNOWN      4        /* Reference to unknown variable */
  39. #define E_MAXVARS      5        /* Maximum variables exceeded */
  40. #define E_BADFUNC      6        /* Unrecognised function */
  41. #define E_NUMARGS      7        /* Wrong number of arguments to funtion */
  42. #define E_NOARG        8        /* Missing an argument to a funtion */
  43. #define E_EMPTY        9        /* Empty expression */
  44.  
  45.